package com.aseo.business.hibernate;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.aseo.model.dao.Dao;
import com.aseo.model.entity.hibernate.Chofer;
import com.aseo.model.entity.hibernate.Vehiculo;


@Service
public class ChoferManager implements ManagerInterface<Chofer> {

	@Resource  
	private Dao dao;
	
	@Override
	public List<Chofer> getAll() {
		final List<Chofer> list = dao.find(Chofer.class);  
	    return list;
	}

	@Override
	public void persist(Chofer chofer) {
		dao.persist(chofer);
	}
	public List<Chofer> getAllActivos(){
		final List<Chofer> list = dao.find("SELECT chofer " +
                "FROM com.aseo.model.entity.hibernate.Chofer chofer " +
                "WHERE chofer.estado=1 ");
		return list;
	}

	public List<Chofer> getChoferByCI(String ci){
		final List<Chofer> list = dao.find("SELECT chofer " +
                "FROM com.aseo.model.entity.hibernate.Chofer chofer " +
                "WHERE chofer.cedula ="+ ci +" AND chofer.estado=1 ");
		
		return list;
	}
	
	public List<Chofer> getChoferByCodigo(String codigo){
		final List<Chofer> list = dao.find("SELECT chofer " +
                "FROM com.aseo.model.entity.hibernate.Chofer chofer " +
                "WHERE chofer.choferId ="+ codigo +" AND chofer.estado=1 ");
		
		return list;
	}
	
}
